<script language="JavaScript" type="text/javascript" src="{$GLOBALS.user_site_url}/system/ext/jquery/jquery.bgiframe.js"></script>
<script language="JavaScript" type="text/javascript" src="{$GLOBALS.user_site_url}/system/ext/jquery/jquery.form.js"></script>
{literal}
<script type="text/javascript">
	$.ui.dialog.prototype.options.bgiframe = true;
	function popUpWindow(url, widthWin, heightWin, title){
		reloadPage = false;
		$("#messageBox").dialog( 'destroy' ).html({/literal}'{capture name="displayJobProgressBar"}<img style="vertical-align: middle;" src="{$GLOBALS.site_url}/system/ext/jquery/progbar.gif" alt="[[Please, wait ...]]" /> [[Please, wait ...]]{/capture}{$smarty.capture.displayJobProgressBar|escape:'quotes'}'{literal});
		$("#messageBox").dialog({
			width: widthWin,
			height: heightWin,
			modal: true,
			title: title
		}).dialog( 'open' );

		$.get(url, function(data){
			$("#messageBox").html(data);
		});

		return false;
	}
</script>
{/literal}
{breadcrumbs}
	<a href="{$GLOBALS.site_url}/manage-polls/">Manage Polls</a>  &#187; {if $action == 'edit'}Edit Poll{else}Add a New Poll{/if}
{/breadcrumbs}

<h1><img src="{image}/icons/bargraph32.png" border="0" alt="" class="titleicon"/>{if $action == 'edit'}Edit Poll{else}Add a New Poll{/if}</h1>

{if $action == 'edit'}
    <p><a href="{$GLOBALS.site_url}/manage-polls/?action=edit_answer&amp;sid={$sid}" class="grayButton">Edit Answers</a> <a href="{$GLOBALS.site_url}/manage-polls/?action=view_results&amp;sid={$sid}" onclick="popUpWindow('{$GLOBALS.site_url}/view-results/?sid={$sid}&action=view_results', 350, 300, '[[View Results]]', true); return false;" class="grayButton">View Results</a></p>
{/if}

{include file="field_errors.tpl"}

<fieldset>
	<legend>&nbsp;Poll Info</legend>
	<form method="post" name='pollInputForm'>
		<input type="hidden" name="sid" value="{$sid}" />
		<input type="hidden" name="action" value="save" />
		<table >
			{foreach from=$form_fields key=field_name item=form_field}
			<tr>
				<td>{$form_field.caption} </td>
				<td>{if $form_field.is_required} <font color="red">*</font>{/if} </td>
				<td width="75%">{input property=$form_field.id}{if $form_field.comment}<br/><small>{$form_field.comment}</small>{/if}</td>
			</tr>
			{/foreach}
			<tr><td colspan="3" >
				<div class="floatRight">
					<input type="submit" name="apply"  class="grayButton" value="Apply" /> <input type="submit" name="save" class="grayButton" value="Save" />
				</div>
			</td></tr>
		</table>
	</form>
</fieldset>